function opt = treatLegacyForceOptions(opt)
    % Internal function for ensuring that both W and Wells are supported as
    % keyword arguments to incompressible solvers.

%{
Copyright 2009-2019 SINTEF Digital, Mathematics & Cybernetics.

This file is part of The MATLAB Reservoir Simulation Toolbox (MRST).

MRST is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

MRST is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with MRST.  If not, see <http://www.gnu.org/licenses/>.
%}

    hasWells = isfield(opt, 'wells');
    hasW = isfield(opt, 'W');
    if hasWells
        Wells = opt.wells;
    else
        Wells = [];
    end
    if hasW
        W = opt.W;
    else
        W = [];
    end
    
    if ~isempty(W)
        assert(isempty(Wells), ...
            'Solver cannot have both legacy ''wells'' argument and ''W'' argument at the same time');
        opt.wells = W;
    end
    if ~isempty(Wells)
        assert(isempty(W), ...
            'Solver cannot have both legacy ''wells'' argument and ''W'' argument at the same time');
        opt.W = Wells;
    end
end
